#!/usr/bin/python3
# -*- coding: utf8 -*-

from libsw3 import *
import os,datetime,time,pymysql,csv,random

def r43():
    '43文件处理'
    序号=1
    字段名称=""
    f=open("20-43.txt","w",encoding="gbk")
    for i in open("col43.txt").readlines():
        if i.startswith(f"{序号}."):
            字段名称=i.split()[1]
            序号=序号+1
            continue
        if 字段名称:
            类型,长度,小数=i.replace("（"," ").split()[:3]
            if 类型 in ["A","C"]:
                小数=0
            f.write(f"{字段名称}|{类型}|{长度}|{小数}\n")
            字段名称=""

def r44():
    '44文件处理'
    序号=1
    字段名称=""
    f=open("20-44.txt","w",encoding="gbk")
    for i in open("col44.txt").readlines():
        if i.startswith(f"{序号}."):
            字段名称=i.split()[1]
            序号=序号+1
            continue
        if 字段名称:
            类型,长度,小数=i.replace("（"," ").split()[:3]
            if 类型 in ["A","C"]:
                小数=0
            f.write(f"{字段名称}|{类型}|{长度}|{小数}\n")
            字段名称=""

sw3.start(globals(),"doc工具")
